$(document).ready(function(){
	
	/*
	var height1 = $(".left_container").height();
	$(".left").height(height1 + 14);
	
	var height2 = $(".right_container").height();
	$(".right").height(height2 + 14);
	*/
	
	
   $(":input[name*='accountType']").change(function(){
      if($(":input[name*='accountType']:checked").attr("id") == "accountTypeJoint"){
	 $('#jointAccountToogle').show('fast');

      }
      else{
	 $('#jointAccountToogle').hide('fast');
      }
   });

   /*hide/show the authorized trader name input div*/
   $("#thirdparty").change(function(){
	   if($("#thirdparty").attr("checked") == true){
		   $("#authorized_trader").show("slow");
	   }
	   else{
		   $("#authorized_trader").hide("slow");
	   }
      }
   );

   $("#currentYears").change(function(){
      if($("#currentYears").val() == '4' || $("#currentYears").val() == ''){
	$("#previousAddress").hide('slow');
      }
      else{
	$("#previousAddress").show('slow');
      }
   });

    $("#jointCurrentYears").change(function(){
      if($("#jointCurrentYears").val() == '4' || $("#jointCurrentYears").val() == ''){
	$("#previousAddress").hide('slow');
      }
      else{
	$("#previousAddress").show('slow');
      }
   });

   $("#separateMailing").change(function(){
	   if($("#separateMailing").attr("checked") == true){
		   $('#mailingAddress').show('slow');
	   }
	   else{
		   $('#mailingAddress').hide('slow');
	   }
    });

    $("#jointSeparateMailing").change(function(){
 	   if($("#jointSeparateMailing").attr("checked") == true){    	
 		   $('#mailingAddress').show('slow');
 	   }
 	   else{
 		   $('#mailingAddress').hide('slow');
 	   }
    });

   $("#countryMain").change(function(){
      $("#homePhoneMain1").val($("#countryMain option:selected").attr('rel'));
      $("#mobilePhoneMain1").val($("#countryMain option:selected").attr('rel'));
   });

   $("#jointCountryMain").change(function(){
	   $("#jointHomePhoneMain1").val($("#jointCountryMain option:selected").attr('rel'));
	   $("#jointMobilePhoneMain1").val($("#jointCountryMain option:selected").attr('rel'));
   });
   
   $("#countryReg").change(function(){
	      $("#phone1").val($("#countryReg option:selected").attr('rel'));
	      $("#mobilePhone1").val($("#countryReg option:selected").attr('rel'));
   });


   $("#citizenship").change(function(){
     if($("#citizenship").val() != ''){
	var sameCountryHtml = "";
	if($("#issCountryHtml").attr('rel') != $("#citizenship option:selected").val()){
	    sameCountryHtml = "<option value='" + $('#citizenship option:selected').val() + "'>" + $('#citizenship option:selected').text() + "</option>";
	}
	$("#issuingCountry").html(
		"<option value=''>Select One</option>" +
		"<option value='" + $('#issCountryHtml').attr('rel') + "'>" + $('#issCountryHtml').val()  + "</option>" +
		sameCountryHtml
	);
	sameCountryHtml = "";
	$(".issCountryHide").show('slow');
     }
     else{
       $(".issCountryHide").hide('slow');
       $(".passNumberHide").hide('slow');
     }
   }
  );

   $("#jointCitizenship").change(function(){
     if($("#jointCitizenship").val() != ''){
	var sameCountryHtml = "";
	if($("#issCountryHtml").attr('rel') != $("#jointCitizenship option:selected").val()){
	    sameCountryHtml = "<option value='" + $('#jointCitizenship option:selected').val() + "'>" + $('#jointCitizenship option:selected').text() + "</option>";
	}
	$("#jointIssuingCountry").html(
		"<option value=''>Select One</option>" +
		"<option value='" + $('#issCountryHtml').attr('rel') + "'>" + $('#issCountryHtml').val()  + "</option>" +
		sameCountryHtml
	);
	sameCountryHtml = "";
	$(".issCountryHide").show('slow');
     }
     else{
       $(".issCountryHide").hide('slow');
       $(".passNumberHide").hide('slow');
     }
   }
  );

   $("#issuingCountry").change(function(){
     if($("#issuingCountry").val() != ''){
	$(".passNumberHide").show('slow');
     }
     else{
	$(".passNumberHide").hide('slow');
     }
   }
  );

   $("#jointIssuingCountry").change(function(){
     if($("#jointIssuingCountry").val() != ''){
	$(".passNumberHide").show('slow');
     }
     else{
	$(".passNumberHide").hide('slow');
     }
   }
  );

   $("#employmentStatus").change(function(){
	if($("#employmentStatus option:selected").val() == 'Employed' ){
	    $("#emplyment_details").show('slow');
	}
	else{
	    $("#emplyment_details").hide('slow');
	}
      
   }
  );

   $("#jointEmploymentStatus").change(function(){
	if($("#jointEmploymentStatus option:selected").val() == 'Employed' ){
	    $("#emplyment_details").show('slow');
	}
	else{
	    $("#emplyment_details").hide('slow');
	}

   }
  );


   $("#foundSourceOther").change(function(){
	   if($("#foundSourceOther").attr("checked") == true){
		   $('#other_found_source').show('fast');
	   }
	   else{
		   $('#other_found_source').hide('fast');
	   }
   });

   $(":input[name*='propertyOwner']").change(function(){
      if($(":input[name*='propertyOwner']:checked").attr("id") == "propertyOwnerYes"){
	 $('#property_value').show('fast');

      }
      else{
	 $('#property_value').hide('fast');
      }
   });


   $("#jointFoundSourceOther").change(function(){
	   if($("#jointFoundSourceOther").attr("checked") == true){
		   $('#other_found_source').show('fast');
	   }
	   else{
		   $('#other_found_source').hide('fast');
	   }
   });

   $(":input[name*='jointPropertyOwner']").change(function(){
      if($(":input[name*='jointPropertyOwner']:checked").attr("id") == "jointPropertyOwnerYes"){
	 $('#property_value').show('fast');

      }
      else{
	 $('#property_value').hide('fast');
      }
   });
   
   
   $("#regInvestment").change(function(){
	   if($("#regInvestment").val() == '1'){
		   $(".investmentReg").show("fast");
	   }
	   else{
		   $(".investmentReg").hide("fast");
	   }
   });
   

});